import config from '../config'
import WechatLib from '../wechat-lib'
import WxAuthor from '../wechat-lib/author'
import mongoose from 'mongoose'
const Token = mongoose.model('Token')
const Ticket = mongoose.model('Ticket')

const options = {
  appID: config.wechat.appID,
  appSecret: config.wechat.appSecret,
  getAccessToken: async () => Token.getAccessToken(),
  saveAccessToken: async data => Token.saveAccessToken(data),
  getTicket: async () => Ticket.getTicket(),
  saveTicket: async data => Ticket.saveTicket(data)
}
export const getWechat = () => new WechatLib(options)
export const getWxAuthor = () => new WxAuthor(options)
